<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html class="bgfff">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>首页</title>
</head>
<body>
	<jsp:include page="/WEB-INF/page/common/_header.jsp" />
	<jsp:include page="/WEB-INF/page/common/head.jsp" />
	<div class="home-nav">
		<ul class="clearfix">
			<li class="clearfix">
				<a href="http://mp.weixin.qq.com/s/8yB2ARNI9vXn8GHSMmLllg">
					<span class="icon icon-intro"></span><br>
					<span class="home-nav-name">子解小林</span>
				</a>
			</li>
			<li class="clearfix">
				<a href="<%=basePath %>/course">
					<span class="icon icon-kc"></span><br>
					<span class="home-nav-name">精品课程</span>
				</a>
			</li>
			<li class="clearfix">
				<a href="<%=basePath %>/media/coach">
					<span class="icon icon-mjfc"></span><br>
					<span class="home-nav-name">名教风采</span>
				</a>
			</li>
			<li class="clearfix">
				<a href="http://mp.weixin.qq.com/s/IfR42_3tMj60JdZ_rBI3wQ">
					<span class="icon icon-gltd"></span><br>
					<span class="home-nav-name">管理团队</span>
				</a>
			</li>
			<li class="clearfix">
				<a href="tel:13380045488">
					<span class="icon icon-llwm"></span><br>
					<span class="home-nav-name">联系我们</span>
				</a>
			</li>
		</ul>
	</div>
	<div class="home-listWrap">
		<div class="home-listTitle">
			<ul class="clearfix">
				<li class="on" author="新闻资讯" page="0"><span>新闻资讯</span></li>
				<li author="学员风采" page="0"><span>学员风采</span></li>
			</ul>
		</div>
		<div class="home-listContentWrap">
			<div class="home-listContent">
				<ul class="clearfix"> </ul>
				<div class="home-listContent-more">
					<a href="javascript:void(0)">查看更多 ></a>
				</div>
			</div>
			<div class="home-listContent none">
				<ul class="clearfix"> </ul>
				<div class="home-listContent-more">
					<a href="javascript:void(0)">查看更多 ></a>
				</div>
			</div>
		</div>
	</div>
	<script id="table-template" type="text/x-handlebars-template">
		{{#if results}}
 		{{#each results}}
			<li class="clearfix">
				<a href="{{url}}">
					<div class="home-listContent-l">
						<img src="${config.imgUrl}{{picUrl}}"/>
					</div>
					<div class="home-listContent-r">
						<p class="home-listContent-title">{{title}}</p>
					</div>
				</a>
			</li>
		{{/each}}
		{{else}}
			<div style="text-align: center;padding-top: 35px;">亲，暂无记录哦</div>
		{{/if}}
	</script>
	<div class="home-pic">
		<div class="home-pic-title clearfix">
			<h4>教练推荐</h4>
			<a href="<%=basePath %>/media/coach">查看更多 ></a>
		</div>
		<div class="home-pic-list">
			<ul class="clearfix">
				<li>
					<a href="http://mp.weixin.qq.com/s?__biz=MzI1NzY4MjU3NQ==&mid=100000034&idx=1&sn=fc3e299409ae54251dc62b8942887abd&chksm=6a12fcc25d6575d4122afa8cd9d4f43c738fc6d0629e889bf6536fda242bc008a5739e2311ce#rd">
						<div>
							<img src="<%=basePath %>/images/club/jl1.png"/><br>
							林著瑾
						</div>
					</a>
				</li>
				</a>
				<li>
					<a href="http://mp.weixin.qq.com/s?__biz=MzI1NzY4MjU3NQ==&mid=100000056&idx=1&sn=1aaf00ca51f002597688788e0b3b6688&chksm=6a12fcd85d6575ce0bfa83861ad2b4f38cce761901c2ce8bb80065f0c96fb35972bf161546f8">
						<div>
							<img src="<%=basePath %>/images/club/jl2.png"/><br>
							韦腾燕
						</div>
					</a>
				</li>
				<li>
					<a href="http://mp.weixin.qq.com/s?__biz=MzI1NzY4MjU3NQ==&mid=100000046&idx=1&sn=14fcd6b2affe9ff2e148d67307a6b365&chksm=6a12fcce5d6575d8f7ebff2cd63a7363d3d6e16814b04d4f399deeba597a1a82a0ca3f0143dc">
						<div>
							<img src="<%=basePath %>/images/club/jl3.png"/><br>
							王睁茗
						</div>
					</a>
				</li>
				<li>
					<a href="http://mp.weixin.qq.com/s?__biz=MzI1NzY4MjU3NQ==&mid=100000047&idx=1&sn=6f18b167c30f7c0407403bf47ccc65e4&chksm=6a12fccf5d6575d91c5161702c4b563fdce52e3fb5d78c1ea4a9f9c18e7d7dbebb225f10c2d3">
						<div>
							<img src="<%=basePath %>/images/club/jl4.png"/><br>
							熊国宝
						</div>
					</a>
				</li>
			</ul>
		</div>
	</div>
	
	<div class="home-pic">
		<div class="home-pic-title clearfix">
			<h4>合作院校</h4>
			<a href="http://mp.weixin.qq.com/s/sHpLkAeyjFoNvTXBFGs_KA">查看更多 ></a>
		</div>
		<div class="home-pic-list">
			<ul class="clearfix">
				<li>
					<div>
						<img src="<%=basePath %>/images/club/fzc.png"/><br>
						风之城足球俱乐部
					</div>
				</li>
				<li>
					<div>
						<img src="<%=basePath %>/images/club/boao.png"/><br>
						博奥体育
					</div>
				</li>
				<li>
					<div>
						<img src="<%=basePath %>/images/club/cq.png"/><br>
						CQ轮滑俱乐部
					</div>
				</li>
				<li>
					<div>
						<img src="<%=basePath %>/images/club/ky.png"/><br>
						坤艺文化
					</div>
				</li>
			</ul>
		</div>
	</div>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script type="text/javascript">
		loadItem();
		$(".home-listTitle li").click(function(){
			var obj = $(this);
			obj.addClass("on").siblings().removeClass("on");
			var listObj = $(".home-listContent:eq("+obj.index()+")");
			listObj.show().siblings().hide();
			if(listObj.find("li").length == 0) {
				loadItem();
			}
		})	
		$(".home-listContent-more").click(function() {
			loadItem();
		});
		function loadItem() {
			var liObj = $(".home-listTitle li.on");
			var pageNo = parseInt(liObj.attr("page")) + 1;
			var author = liObj.attr("author");
			var listObj = $(".home-listContent:eq("+liObj.index()+")");
			$.ajax({
			    type: 'post',
			    url: '<%=basePath %>/media/list',
			    data: {
			    	page: pageNo,
			    	author: author
			    },
			    dataType: 'json',
			    cache:false,
			    success: function(data) {
			    	var myTemplate = Handlebars.compile($("#table-template").html());

			    	listObj.find("ul").append(myTemplate(data));
			    	
			    	
		        	
			    	if(data.results && data.results.length > 0) {
			        	if(pageNo == data.totalPage) {
			        		$(".home-listContent-more:eq("+liObj.index()+")").attr("style","display:none;");
			        	}else {
			        		liObj.attr("page", pageNo);
			        	}
			        }else {
			        	$(".home-listContent-more:eq("+liObj.index()+")").attr("style","display:none;");
			        }
			    	
			    },
			    error:function(){
                	alert("系统异常，请稍后再试！");
                },
			    complete:function(){
                	if(!listObj.hasClass("list-null")){
                		listObj.find(".loader").hide();
                	}
                }
			});
		}
	</script>
</body>
</html>